import $ from "jquery";
import {url} from "../../util/config";
import {message} from "antd";
import login from "../login";
function getNewLogin(item) {
    return getBreadCrumbs(item)
}
export default function getBreadCrumbs(item) {
    //#1 folder-d,article-d,file-d,folder,file,article ; #2 folder-d id,file-d id，folderId，fileId,articleId
    console.log("type:item.type , id:",item.id)
    // let usersBind = [];
    let token = localStorage.getItem("token")
    let breadCrumbList = [];
    $.ajax({
        async:false,
        method:"GET",
        headers: {
            'Accept': "application/json",
            'Authorization': token
        },
        url: url.api_url+`UserPage/breadcrumb?type=${item.type}&id=${item.id}`,
        success: function (result) {
            if(result.result=="Token過期請重新登錄"){
                login(localStorage.getItem("account"), localStorage.getItem("password"));
                breadCrumbList = getNewLogin(item)
            }else {
                breadCrumbList = result.result
            }
        },
        error:function (error) {
            message.error("请求异常");
        }
    })
    return breadCrumbList;
}
